import tkinter as tk
from puzzle import Puzzle
from grid import Grid
from tools import Tools


class App(tk.Tk):
    def __init__(self):
        super().__init__()
        screen_width = self.winfo_screenwidth()
        screen_height = self.winfo_screenheight()
        window_width = 1000
        window_height = 530

        center_x = int(screen_width / 2 - window_width / 2)
        center_y = int(screen_height / 2 - window_height / 2)

        self.geometry(f"{window_width}x{window_height}+{center_x}+{center_y}")
        self.resizable(False, False)

        self.title("Sudoku")


def main():
    s = """
[179]38 4[27][125] [259][1569][269] 
2[47][17] 9[67][156] [45]38 
[149]65 38[12] 7[19][249] 

[578][589][279] [2678]3[269] 14[269] 
6[4789]3 [278]1[249] [289][79]5 
[478]1[279] [2678]5[2469] [289][679]3 

[78][78]4 593 621 
32[169] [16][46]8 [459][59]7 
[15][59][169] [126][246]7 38[49] 
"""

    grid = Grid()
    grid.decode(s)
    grid.init()
    grid.clearup()

    app = App()
    puzzle = Puzzle(app, grid)
    tools = Tools(app, puzzle)
    app.mainloop()


if __name__ == "__main__":
    main()
